/*
 * MoleCalculator.java
 * 
 * Calculates the amount of moles in a x amount of grams of y element
 * 
 * Author: Andres Ruiz
 * License: see License.txt
 */
public class MoleCalculator
{
	private double AtomicMass;
	private String element;
	private double GramsOfElement;
	private String searchResults;
	private double MolesOfElement;
	PeriodicTableAcess get;
	InfoStringParse infoParse;
	
	public MoleCalculator(double gramsOfEle, String Ele)
	{
		GramsOfElement = gramsOfEle;
		element = Ele;
		Moles();
	}

	private void getElementInfo()
	{
		get = new PeriodicTableAcess(element);
		searchResults = get.getSearchResult();
		infoParse = new InfoStringParse(searchResults);
		AtomicMass = infoParse.getAtomicMass();
	}

	private void Moles()
	{
		getElementInfo();
		MolesOfElement = GramsOfElement/AtomicMass;
	}
	
	public void PrintResults()
	{
		System.out.println(GramsOfElement + " / " + AtomicMass + " = " + MolesOfElement);
		System.out.println();
		System.out.println("You have " + MolesOfElement + " moles of " + infoParse.getName());
	}
	
	public double getResults()
	{
		return MolesOfElement;
	}
}
